package bookSystem.operations;

import bookSystem.book.Book;
import bookSystem.book.BookList;

import java.util.Scanner;

public class FindOperatiion implements IOperation{
    //查找图书
    public void work(BookList bookList){
        System.out.println("查找图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入查找书名：");
        String name = scanner.nextLine();
        int count = 0;
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (name.equals(book.getName())){
                System.out.println(book.toString());
                count++;
            }
        }
        if (count==0){
            System.out.println("没有找到该图书");
        }
    }
}
